Skip to content

Add batch actions (purge, query orchestrations/entities)#111

Open
andystaples wants to merge 16 commits intomainfrom
andystaples/add-batch-actions
Open

Add batch actions (purge, query orchestrations/entities)#111
andystaples wants to merge 16 commits intomainfrom
andystaples/add-batch-actions

Conversation

@andystaples
Copy link
Contributor

Adds batch actions for orchestration/entity management

@andystaples
Copy link
Contributor Author

@copilot Can you open a PR to these changes that adds the necessary tests to the newly-added test files covering an acceptable set of use cases for each of the newly added actions? Please update the durabletask test to match the durabletask-azuremanaged one as well

Copy link

Copilot AI commented Feb 12, 2026

@andystaples I've opened a new pull request, #112, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds batch operation support for managing orchestrations and entities, enabling querying and purging of multiple instances at once. The changes introduce new client methods for batch queries and purges, along with supporting infrastructure and tests.

Changes:

  • Added batch query methods (get_all_orchestration_states, get_orchestration_state_by, get_all_entities, get_entities_by) to retrieve multiple orchestration and entity instances with filtering capabilities
  • Added batch purge method (purge_orchestrations_by) to delete multiple orchestration instances based on filters
  • Enhanced existing purge_orchestration method to return a PurgeInstancesResult with information about deleted instances
  • Refactored orchestration state parsing logic to support both single-instance and batch queries
  • Added deprecation to EntityMetadata.from_entity_response in favor of from_entity_metadata
  • Added helper function get_int_value for wrapping optional integers in protobuf messages

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
tests/durabletask/test_batch_actions.py New test file for batch orchestration query operations using the TaskHubGrpcClient
tests/durabletask-azuremanaged/test_dts_batch_actions.py New test file for batch orchestration query operations using DurableTaskSchedulerClient with support for fetching inputs/outputs
durabletask/internal/helpers.py Added get_int_value helper function for wrapping optional integers in protobuf Int32Value
durabletask/entities/entity_metadata.py Deprecated from_entity_response method and refactored to use new from_entity_metadata method for better separation of concerns
durabletask/client.py Added batch query/purge methods for orchestrations and entities, refactored state parsing, updated existing methods to use helper functions, and added PurgeInstancesResult class
Comments suppressed due to low confidence (1)

durabletask/entities/entity_metadata.py:3

  • The deprecated decorator from the warnings module was introduced in Python 3.13, but this project requires Python 3.10+ (as specified in pyproject.toml). This will cause an ImportError on Python 3.10, 3.11, and 3.12. Consider using an alternative deprecation approach such as warnings.warn(DeprecationWarning(...)) inside the function, or a third-party library that supports older Python versions.
from durabletask.entities.entity_instance_id import EntityInstanceId

andystaples and others added 10 commits February 12, 2026 14:09
* Initial plan

* Add comprehensive batch action tests and clean_entity_storage method

Co-authored-by: andystaples <77818326+andystaples@users.noreply.github.com>

* Merge base branch and resolve conflicts

Co-authored-by: andystaples <77818326+andystaples@users.noreply.github.com>

* Address PR review comments on test improvements

Co-authored-by: andystaples <77818326+andystaples@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: andystaples <77818326+andystaples@users.noreply.github.com>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewers - I'm not sure these tests are worth adding, tbh. If we ever implement these gRPC endpoints into the Go sidecar, our tests will immediately break. Any objection to just commenting them out for now, and relying on the DTS tests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, it looks like they're just a reminder for us to write tests once they are implemented. However, I'm confused why they rely on the go sidecar since we're in the python SDK? If they can break from a PR outside of this repo, I think they become less useful.

If this is truly just a test for the go sidecar, I would rather we have those in the go repo. Can you expand on this a little bit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The durabletask (non-DTS) tests use the Go sidecar as the emulator for the durability layer, just like how the DTS tests use the DTS emulator docker image, yes, it's testing two things but AFAIK, and this was before my time, it was the easiest way to set up E2E for this project.
I'll go ahead and remove these tests, with a note to add them when possible

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

fetch_inputs_and_outputs=fetch_inputs_and_outputs
)

def get_orchestration_state_by(self,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a strange method name - is this what we use in other SDKs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least in .NET, we just have 1 method which takes an optional filter.

https://github.com/microsoft/durabletask-dotnet/blob/main/src/Client/Grpc/GrpcDurableTaskClient.cs#L280

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the Funtions Python SDK, but probably better to match the other portable SDKs and have the translation layer for Functions + durabletask python. Will update this in future commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to match .NET - takes a Filter instead of a list of params, and there is one method for each. Also removed _continuation_token from the public API

Copy link
Member

@halspang halspang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nit and a question to go along with the other comments.

) -> List[OrchestrationState]:
if max_instance_count is None:
# Some backends do not behave well with max_instance_count = None, so we set to max 32-bit signed value
max_instance_count = (1 << 31) - 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Is there no int.max in python?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, int values are unbounded in python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments